﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using IFRS.DataAccess.DAL;
namespace IFRS.DataAccess.DAL
{
    public class MENU_SYSTEM
    {
        public DataTable GET_SMENU_SYSTEM(int? iMENU_SYSTEM_ID)
        {
            DataTable dt = new DataTable();
            IFRS_Utility Utility = new IFRS_Utility();
            List<SqlParameter> lstParams = new List<SqlParameter>();
            try
            {
                lstParams.Add(new SqlParameter("@MENU_SYSTEM_ID", iMENU_SYSTEM_ID));
                dt = Utility.StoredProcDataTable("PKG_GET_SMENU_SYSTEM", lstParams.ToArray());
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return dt;
        }

        public int INSERT_TEST(int iID_TEST,string sTEST_NAME)
        {
            int iNum = 0;
            IFRS_Utility Utility = new IFRS_Utility();
            List<SqlParameter> lstParams = new List<SqlParameter>();
            try
            {
                lstParams.Add(new SqlParameter("@ID_TEST",SqlDbType.Int));
                lstParams[0].Direction = ParameterDirection.Output;

                lstParams.Add(new SqlParameter("@TEST_NAME", sTEST_NAME));
                Utility.ExecuteStoredProc("PKG_INSERT_TEST", lstParams.ToArray());

                iNum = (int)lstParams[0].Value;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return iNum;
        }

        public int UPDATE_TEST(int iID_TEST, string sTEST_NAME)
        {
            int iNum = 0;
            IFRS_Utility Utility = new IFRS_Utility();
            List<SqlParameter> lstParams = new List<SqlParameter>();
            try
            {
                lstParams.Add(new SqlParameter("@ID_TEST", iID_TEST));
                lstParams.Add(new SqlParameter("@TEST_NAME", sTEST_NAME));
                iNum = (int)Utility.ExecuteStoredProc("PKG_UPDATE_TEST", lstParams.ToArray());
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return iNum;
        }

        public int DELETE_TEST(int iID_TEST)
        {
            int iNum = 0;
            IFRS_Utility Utility = new IFRS_Utility();
            List<SqlParameter> lstParams = new List<SqlParameter>();
            try
            {
                lstParams.Add(new SqlParameter("@ID_TEST", iID_TEST));
                iNum = (int)Utility.ExecuteStoredProc("PKG_DELETE_TEST", lstParams.ToArray());
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return iNum;
        }

    }
}
